#ifndef RP2INITIALIZEMCR_H
#define RP2INITIALIZEMCR_H

#define RP2_DECLARE_INITIALIZE \
public: \
	static void Initialize(); \
	static bool RegisterInitialize(); \
private: \
	static bool ms_bInitializeRegistered
//---------------------------------------------------------------------------------------------------
#define RP2_REGISTER_INITIALIZE(classname) \
	static bool gs_bInitializeRegistered_##classname = \
		classname::RegisterInitialize()
//---------------------------------------------------------------------------------------------------
#define RP2_IMPLEMENT_INITIALIZE(classname) \
	bool classname::ms_bInitializeRegistered = false; \
	bool classname::RegisterInitialize() \
	{ \
		if (!ms_bInitializeRegistered) \
		{ \
			Main::AddInitializer(classname::Initialize); \
			ms_bInitializeRegistered = true; \
		} \
		return ms_bInitializeRegistered; \
	}
//---------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------
#define RP2_DECLARE_TERMINATE \
public: \
    static bool RegisterTerminate (); \
    static void Terminate (); \
private: \
    static bool ms_bTerminateRegistered
//---------------------------------------------------------------------------------------------------
#define RP2_IMPLEMENT_TERMINATE(classname) \
bool classname::ms_bTerminateRegistered = false; \
bool classname::RegisterTerminate () \
{ \
    if (!ms_bTerminateRegistered) \
    { \
        Main::AddTerminator(classname::Terminate); \
        ms_bTerminateRegistered = true; \
    } \
    return ms_bTerminateRegistered; \
}
//---------------------------------------------------------------------------------------------------
#define RP2_REGISTER_TERMINATE(classname) \
static bool gs_bTerminateRegistered_##classname = \
    classname::RegisterTerminate ()
//---------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------
#define RP2_WINDOW_APPLICATION(classname) \
	RP2_IMPLEMENT_INITIALIZE(classname); \
	void classname::Initialize() \
	{ \
		Application::Run = &WindowApplication::Run; \
		TheApplication = new classname; \
	}
//---------------------------------------------------------------------------------------------------
#endif